InfomationGridPanel = function(){
	var data = [
		{aid:1,fouceimgid:1,title:'AAAA',secondtitle:'AA',content:'AAAAAA',foucestopic:'1',gototopic:'1',specialstyle:'1',shortcutnote:'A',datetime:'',username:'AAAAAAAAA'},
		{aid:2,fouceimgid:2,title:'BBBB',secondtitle:'BB',content:'BBBBBB',foucestopic:'0',gototopic:'0',specialstyle:'0',shortcutnote:'B',datetime:'',username:'BBBBBBBBB'},
		{aid:3,fouceimgid:3,title:'CCCC',secondtitle:'CC',content:'CCCCCC',foucestopic:'1',gototopic:'1',specialstyle:'1',shortcutnote:'C',datetime:'',username:'CCCCCCCCC'}
	];
	var url = __ctxPath+'/back/article/findarticleinfo.html';
	var store = new Ext.data.JsonStore(
		{
//			data:data,
			url:url,
			totalProperty:'totalCount',
			root:'data',
			autoLoad:true,
			fields:[
				'aid','fouceimgid','title',
				'secondtitle','foucestopic',
				'gototopic','specialstyle',
				'shortcutnote','datetime','username',
				'keyword','filecounts','fouceimgid'
			]
		}
	);
	var num = new  Ext.grid.RowNumberer();
	var sc = new Ext.grid.CheckboxSelectionModel();
	var editOnlyOneInfo = function(grid, rowIndex, colIndex){
		var rec = store.getAt(rowIndex);
		App.clickTopTab('EditInfomationPanel',rec);
	};
	var deleteOnlyOneInfo = function(grid, rowIndex, colIndex){
		Ext.MessageBox.confirm('系统提示','确定删除?',
			function(btn){
				var rec = store.getAt(rowIndex);
				if(btn=='yes'){
					Ext.Ajax.request(
						{
							params:{aid:rec.get('aid')},
							url:__ctxPath+'/back/article/deleteinfo.html',
							success:function(response,option){
								var obj = Ext.decode(response.responseText);
								if(obj.success){
									SX.Util.msg('系统提示','删除成功!');
									store.reload();
								}else{
									SX.Util.msg('系统提示','删除失败!');
								}
							},
							failure:function(response,option){
								SX.Util.msg('系统提示','网络原因,删除失败!');
							}
						}
					);
				}
			}
		);
	};
	var cm = [
		num,sc,
		{
			header:"标题",dataIndex:"title",width:120
		},{
			header:"副标题",dataIndex:"secondtitle",width:120
		},{
			header:"录入用户",dataIndex:"username",width:150
		},{
			header:"附件数量",dataIndex:"filecounts",width:100
		},{
			header:"关键词",dataIndex:"keyword",width:130
		},{
			header:"是否为焦点新闻",dataIndex:"foucestopic",width:100,renderer:function(value){
				if(value==1){
					return '<span style="color:green">焦点信息</span>';
				}else{
					return '<span style="color:red">普通</span>';
				}
			}
		},{
			header:"是否置顶",dataIndex:"gototopic",width:100,renderer:function(value){
				if(value==1){
					return '<span style="color:green">置顶</span>';
				}else{
					return '<span style="color:red">普通</span>';
				}
			}
		},{
			header:"是否特殊样式",dataIndex:"specialstyle",width:100,renderer:function(value){
				if(value==1){
					return '<span style="color:green">特殊样式</span>';
				}else{
					return '<span style="color:red">普通</span>';
				}
			}
		},{
			header:"录入时间",
			dataIndex:"datetime",
			width:145,
			renderer:function(value){
				return value.substring(0,19);
			}
		},{
            xtype: 'actioncolumn',
            header:'操作',
            width: 50,
            items: [
	            {
	                iconCls :'edit',
	                tooltip: '编辑信息',
	                handler: editOnlyOneInfo
	            }, {
	                iconCls :'delete',
	                tooltip: '删除信息',
	                handler: deleteOnlyOneInfo
	            }
	         ]
        }
	];
	var grid = new Ext.grid.GridPanel(
		{
			store:store,
			width:500,
			height:400,
			columns:cm
		}
	);
	var bbar = [
		new Ext.PagingToolbar(
			{
				 store: store,       // grid and PagingToolbar using same store
        		 displayInfo: true,
        		 pageSize: 20,
        		 plugins: new Ext.ux.ProgressBarPager({progBarWidth:400})
			}
		)
	];
	var searchbox = new Ext.form.TwinTriggerField({
	   	validationEvent:false,
	   	validateOnBlur:false,
	   	trigger1Class:'x-form-clear-trigger',
	   	trigger2Class:'x-form-search-trigger',
	   	hideTrigger1:true,
	   	width:300,
	   	hasSearch : false,
       	paramName : 'query',
       	listeners:{'specialkey':function(f, e){
       		if(e.getKey() == e.ENTER){
				this.onTrigger2Click();
			}
	   	}},
       	onTrigger1Click : function(){
			if(this.hasSearch){
				this.el.dom.value = '';
				this.triggers[0].hide();
				this.hasSearch = false;
				this.focus();
			}
		},
		onTrigger2Click : function(){
			var v = this.getRawValue();
			var _url = __ctxPath+'/back/article/findarticleinfo.html';
			var _obj = {start:0,limit:20,title:v};
			var _store=store;
			_store.proxy.setUrl(_url,true);
			_store.baseParams = _obj;
			_store.load({params:_obj});
			this.hasSearch = true;
			this.triggers[0].show();
			this.focus();
		}			
	});
	var tbar = [
		{
			text:'新增信息',
			iconCls:'add',
			handler:function(){
				App.clickTopTab('AddInfomationPanel');
			}
		},'-',{
			text:'查询信息',
			iconCls:'zoom',
			handler:function(){
				var winquery = new QueryInfoWindow();
				winquery.show();
				winquery.on('submit',
					function(win,form){
						var o = form.getForm().getValues();
						var _obj = {start:0,limit:20,title:o.title,datetime:o.datetime};
						if(_obj.title==''){
							delete _obj.title;
						}
						if(_obj.datetime == ''){
							delete _obj.datetime;
						}
						var _store=store;
						var _url = __ctxPath+'/back/article/findarticleinfo.html';
						_store.proxy.setUrl(_url,true);
						_store.baseParams = _obj;
						_store.load({params:_obj});
					}
				);
			}
		},'-',searchbox
	];
	var config = {
		tbar:tbar,
		bbar:bbar,
		title:'文章列表信息',
		id:'InfomationGridPanel',
		layout:"fit",
		iconCls:'application',
		width:500,
		height:400,
		items:[grid]
	}
	InfomationGridPanel.superclass.constructor.call(this,config);
};
Ext.extend(InfomationGridPanel,Ext.Panel);